<?php
require_once 'classes/Database.php';
require_once 'classes/OrderManager.php';
require_once 'classes/CDKManager.php';

$orderManager = new OrderManager();
$cdkManager = new CDKManager();

// 检查特定订单
$orderNo = '202509290112168467';
$order = $orderManager->getOrderByNo($orderNo);

echo "订单详情:\n";
print_r($order);

// 检查该订单是否分配了CDK码
if ($order) {
    $assignedCDK = $cdkManager->getCDKByOrderId($order['id']);
    echo "\n该订单分配的CDK码:\n";
    print_r($assignedCDK);
    
    // 检查该商品是否有可用的CDK码
    $availableCDK = $cdkManager->getAvailableCDK($order['product_id']);
    echo "\n该商品可用CDK码:\n";
    print_r($availableCDK);
    
    // 检查订单的CDK码字段
    echo "\n订单CDK码字段: " . ($order['cdk_code'] ?: '空') . "\n";
}
?>
